package com.neutech.controller;

import com.neutech.service.PinspectService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@CrossOrigin
@RestController
public class PinspectController {

    @Autowired
    private PinspectService pinspectService;

    @ResponseBody
    @RequestMapping("/namepinspect")
    public List<Map<String, Object>> queryPinspectByName(@RequestParam Map map)
    {


        List<Map<String, Object>> list = pinspectService.queryPinspectByName(map.get("name").toString());
        System.out.println(list);
        return pinspectService.queryPinspectByName(map.get("name").toString());

    }
    @ResponseBody
    @RequestMapping("/mesinspect")
    public List<Map<String, Object>> queryInspectByName(@RequestParam Map map)
    {
        List<Map<String, Object>> list = pinspectService.queryInspectByName(map.get("name").toString());
        System.out.println(list);
        return list;
    }
    @ResponseBody
    @RequestMapping("/addpinspect")
    public void addPinspect(@RequestParam Map map)
    {
        for (Object key : map.keySet())
        {
            String value = (String)map.get(key);

            System.out.println(key + " : " + value);
        }
        pinspectService.addPinspect(map);
    }
    @ResponseBody
    @RequestMapping  ("/delpinspect")
    public void delpinspect(@RequestParam Map map)
    {
        System.out.println(map.get("num"));
        pinspectService.delpinspect(Integer.parseInt(map.get("num").toString()));

    }
    @ResponseBody
    @RequestMapping  ("/idpinspect")
    public List<Map<String, Object>> idpinspect(@RequestParam Map map)
    {
        System.out.println(map.get("idnumber"));
       return pinspectService.queryPinspectByIdnumber(Integer.parseInt(map.get("idnumber").toString()));

    }

}
